package com.cskaoyan.javase.oop3._1interface._5extend;

/**
 * 接口和抽象类在方法的传参以及方法的返回值中的应用
 *      当接口或者抽象类作为方法的形参数据类型或者返回值类型时
 *      只能传入或者返回它们的子类对象(因为它们自身没有对象)
 *
 * @since 09:47
 * @author wuguidong@cskaoyan.onaliyun.com
 */
public class Demo {
    public static void main(String[] args) {
        test(new Father());
        test(new Son());

        test(new A());
        test(new IAImpl());
    }

    public static void test(Father f){}
    public static Father test(){
        // return new Father();
        return new Son();
    }

    public static void test(BaseA ba){}
    public static void test(IA ba){}

    public static BaseA test2(){
        return new A();
    }
    public static IA test3(){
        return new IAImpl();
    }
}

class Father{}
class Son extends Father{}
abstract class BaseA {
}

interface IA {
}

class IAImpl implements IA {
}

class A extends BaseA {
}